package com.heima.wemedia.feign;

import com.heima.apis.wemedia.IWemediaClient;
import com.heima.model.admin.dtos.*;
import com.heima.model.article.dtos.UpOrDownDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmNewsDto;
import com.heima.model.wemedia.pojos.WmChannel;
import com.heima.model.wemedia.pojos.WmSensitive;
import com.heima.wemedia.service.WmChannelService;
import com.heima.wemedia.service.WmNewsService;
import com.heima.wemedia.service.WmSensitiveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class WemediaClient implements IWemediaClient {

    @Autowired
    private WmChannelService wmChannelService;

    @Autowired
    private WmSensitiveService wmSensitiveService;

    @Autowired
    private WmNewsService wmNewsService;

    @GetMapping("/api/v1/channel/list")
    @Override
    public ResponseResult getChannels() {
        return wmChannelService.findAll();
    }

    @PostMapping("/api/v1/channel/list")
    @Override
    public ResponseResult getChannelList(@RequestBody ChannelDto dto) {
        ResponseResult channelList = wmChannelService.getChannelList(dto);
        return channelList;
    }

    @PostMapping("/api/v1/channel/save")
    @Override
    public ResponseResult saveChannel(@RequestBody WmChannel channel) {
        return wmChannelService.saveChannel(channel);
    }

    @PostMapping("/api/v1/channel/update")
    @Override
    public ResponseResult UpdateChannel(@RequestBody WmChannel channel) {
        return wmChannelService.updateChannel(channel);
    }

    @GetMapping("/api/v1/channel/del/{id}")
    @Override
    public ResponseResult deleteChannel(@PathVariable Integer id) {
        return wmChannelService.deleteChannel(id);
    }

    @PostMapping("/api/v1/sensitive/list")
    @Override
    public ResponseResult getSensitives(@RequestBody SensitiveDto dto) {
        return wmSensitiveService.getSensitives(dto);
    }

    @PostMapping("/api/v1/sensitive/save")
    @Override
    public ResponseResult saveSensitive(@RequestBody WmSensitive sensitive) {
        return wmSensitiveService.saveSensitive(sensitive);
    }

    @PostMapping("/api/v1/sensitive/update")
    @Override
    public ResponseResult updateSensitive(@RequestBody WmSensitive sensitive) {
        return wmSensitiveService.updateSensitive(sensitive);
    }

    @DeleteMapping("/api/v1/sensitive/del/{id}")
    @Override
    public ResponseResult deleteSensitive(@PathVariable Integer id) {
        return wmSensitiveService.deleteSensitive(id);
    }

    @PostMapping("/api/v1/news/list_vo")
    @Override
    public ResponseResult getNewsList(@RequestBody NewsDto dto) {
        return wmNewsService.getNewsList(dto);
    }

    @GetMapping("/api/v1/news/one_vo/{id}")
    @Override
    public ResponseResult getNewsContent(@PathVariable Integer id) {
        return wmNewsService.getNewsContent(id);
    }

    @PostMapping("/api/v1/news/auth_fail")
    @Override
    public ResponseResult boHui(@RequestBody BhDto dto) {
        return wmNewsService.boHui(dto);
    }

    @PostMapping("/api/v1/news/auth_pass")
    @Override
    public ResponseResult newsTg(@RequestBody NewsTgDto dto) {
        return wmNewsService.passAuth(dto);
    }

    @PostMapping("/api/v1/admin/constant/list")
    @Override
    public ResponseResult getConnentList(@RequestBody ConnentDto dto) {
        return wmNewsService.getConnentList(dto);
    }

    @PostMapping("/api/v1/article/up")
    @Override
    public ResponseResult up(@RequestBody UpOrDownDto dto) {
        return wmNewsService.up(dto);
    }

    @PostMapping("/api/v1/article/down")
    @Override
    public ResponseResult down(@RequestBody UpOrDownDto dto) {
        return wmNewsService.down(dto);
    }

}
